package com.itheima.sh.service.impl;

import com.github.pagehelper.PageHelper;
import com.itheima.sh.mapper.UserMapper;
import com.itheima.sh.pojo.User;
import com.itheima.sh.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> findAll() {
        PageHelper.startPage(1, 5);//分页
        return this.userMapper.findAll();
    }

    @Override
    public User findUser(Integer id) {
        return this.userMapper.findUser(id);
    }

    @Override
    public void addUser(User user) {
        this.userMapper.addUser(user);
    }

    @Override
    public void updateUser(Integer id, User user) {
        this.userMapper.updateUser(id, user);
    }

    @Override
    public void deleteUser(Integer id) {
        this.userMapper.deleteUser(id);
    }
}
